package org.jay.angla.dialog;

import org.jay.angla.onlab.R;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class QASampleDialog extends Dialog {

	private EditText mNameEditText;
	private EditText mConcEditText;
	private Button mSureButton;
	private Button mTestButton;
	private Button mCancelButton;
	private Context mContext;
	private int mIndex;

	public QASampleDialog(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		setThisDialog();
		setTitle(context.getString(R.string.qa_sample_dialog_title));
		mContext = context;
	}

	private void setThisDialog() {
		View mView = LayoutInflater.from(getContext()).inflate(
				R.layout.dialog_set_sample, null);
		super.setContentView(mView);
		mNameEditText = (EditText) mView.findViewById(R.id.et_name);
		mConcEditText = (EditText) mView.findViewById(R.id.et_conc);
		mSureButton = (Button) mView.findViewById(R.id.dialog_sample_ok_button);
		mTestButton = (Button) mView.findViewById(R.id.dialog_sample_test_button);
		mCancelButton = (Button) mView.findViewById(R.id.dialog_sample_cancel_button);
		setCancelable(false);
	}

	public int getIndex() {
		return mIndex;
	}

	public void setOnClickListener(View.OnClickListener listener) {
		mSureButton.setOnClickListener(listener);
		mCancelButton.setOnClickListener(listener);
		mTestButton.setOnClickListener(listener);
	}

	public void show(int id, String name, String conc) {
		mIndex = id;
		setNameEditText(name);
		setConcEditText(conc);
		show();
	}

	public String getNameEditText() {
		return mNameEditText.getEditableText().toString();
	}

	public String getConcEditText() {
		return mConcEditText.getEditableText().toString();
	}

	public void setNameEditText(String name) {
		mNameEditText.setText(name);
	}

	public void setConcEditText(String conc) {
		mConcEditText.setText(conc);
	}
}
